package com.caishi.lkx.common.role;

import com.caishi.lkx.common.NacosDiamond;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author by keray
 * date:2021/4/6 3:28 下午
 */
@Configuration
@ConfigurationProperties(prefix = "nacos.config.role")
public class RoleAuthConfig implements NacosDiamond {

    @Value("${server.servlet.context-path}")
    private String contextPath;

    public final Map<String, String> swagger = new HashMap<>();

    private long confLastTime = 0;

    public void beforeReBind() {
        NacosDiamond.super.beforeReBind();
        confLastTime = System.currentTimeMillis();
    }


    @Getter
    @Setter
    private Map<String, String> conf;

    @PostConstruct
    public void init() {
        swagger.putAll(new HashMap<>() {{
            put(contextPath + "/swagger.*", "none");
            put(contextPath + "/api-docs.*", "none");
            put(contextPath + "/v3/api-docs.*", "none");
            put(contextPath + "/v3/swagger.*", "none");

        }});
    }


    public long getConfLastTime() {
        return confLastTime;
    }
}
